
import Header from '@/components/stats/Header.vue'
import Footer from '@/components/stats/Footer.vue'

import wsHeartMixin from '@/common/mixins/wsHeartMixin'

export default {
  mixins: [wsHeartMixin],
  components: {
    Header,
    Footer
  },
  data () {
    return {
      statsData: [],
      innerStyle: [],
      sortStatsData:[],
      currnetArea: '',
      areaData: [],
      sortAreaData: [],
      currnetPoint: '',
      pointData: [],
      sortPointData: []
    }
  },
  mounted () {
    if(sessionStorage.getItem('statsData') && sessionStorage.getItem('statsData') !== 'undefine') {
      this.setAreaData()
    }
    this.setInnerStyle()
    window.addEventListener('resize', () => {
      this.setInnerStyle()
    })
    // this.getStatsData()
    this.linkWs()
  },
  methods: {
    linkWs () {
      this.ws.url += "/ws/statis/fetchData"
      this.createWebSocket()
    },
    handleWsData(data){
      sessionStorage.setItem('statsData', JSON.stringify(data))
      this.setAreaData()
    },
    getStatsData () {
      console.log(111)
      this.$http.getStatsData().then((res) => {
        console.log(res)
        if (res.msg === 'success') {
          sessionStorage.setItem('statsData', JSON.stringify(res.data))
          this.setAreaData()
        }
      })
    },
    setAreaData () {
    },
    setInnerStyle () {
      this.innerStyle = {
        'width': '2000px',
        'transform': `scale(${window.innerWidth / 2000})`,
        'transform-origin': 'left top 0px'
      }
    }
  }
}